package com.lxlg.lxlg_order.consumer;

import com.lxlg.lxlg_order.service.service.GoodsOrderService;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@RocketMQMessageListener(consumerGroup = "formOrder_cancle",topic = "formOrder_cancle")
//取消普通订单
public class CancleFormOrder implements RocketMQListener<String>, RocketMQPushConsumerLifecycleListener {

    @Resource
    private RedisTemplate redisTemplate;

    @Resource
    private GoodsOrderService goodsOrderService;

    @Override
    public void onMessage(String message) {


        goodsOrderService.cancleFormOrder(message);
        //
    }

    @Override
    public void prepareStart(DefaultMQPushConsumer consumer) {
        //设置重试次数
        consumer.setMaxReconsumeTimes(1);
    }
}
